home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!cs.odu.edu!Amiga-Request
- From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
- Newsgroups: comp.sources.amiga
- Subject: v90i169: ColdReboot.s 2 - offcial way to reboot under software control, Part01/01
- Message-ID: <12569@xanth.cs.odu.edu>
- Date: 20 May 90 21:12:05 GMT
- Sender: news@cs.odu.edu
- Reply-To: bryce@cbmvax.commodore.com (Bryce Nesbitt)
- Lines: 179
- Approved: tadguy@cs.odu.edu (Tad Guy)
- X-Mail-Submissions-To: Amiga@cs.odu.edu
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: bryce@cbmvax.commodore.com (Bryce Nesbitt)
- Posting-number: Volume 90, Issue 169
- Archive-name: examples/coldreboot-2/part01
-
- Sometimes applications need to be able to reboot the Amiga under software
- control. However, rebooting the machine is very tricky, and most attempts
- have been flawed. ...
-
- The ColdReboot() function listed below should be used whenever an application
- needs to reboot the Amiga. ColdReboot() is the only officially supported way
- to reboot an Amiga under software control.
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 1)."
- # Contents: coldreboot.s readme
- # Wrapped by tadguy@xanth on Sun May 20 17:11:52 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'coldreboot.s' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'coldreboot.s'\"
- else
- echo shar: Extracting \"'coldreboot.s'\" \(2313 characters\)
- sed "s/^X//" >'coldreboot.s' <<'END_OF_FILE'
- X****************************************************************************
- X*
- X* NAME
- X* ColdReboot - Official code to reset any Amiga (Version 2)
- X*
- X* SYNOPSIS
- X* ColdReboot()
- X*
- X* void ColdReboot(void);
- X*
- X* FUNCTION
- X* Reboot the machine. All external memory and peripherals will be
- X* RESET, and the machine will start its power up diagnostics.
- X*
- X* NOTE
- X* Rebooting an Amiga in software is very tricky. Differing memory
- X* configurations and processor cards require careful treatment. This
- X* code represents the best available general purpose reset.
- X*
- X* The MagicResetCode must be used exactly as specified here. The code
- X* _must_ be longword aligned. Failure to duplicate the code EXACTLY
- X* may result in improper operation under certain system configurations.
- X*
- X* RESULT
- X* This function never returns.
- X*
- X****************************************************************************
- X
- X INCLUDE "exec/types.i"
- X INCLUDE "exec/libraries.i"
- X
- X XDEF _ColdReboot
- X XREF _LVOSupervisor
- X
- XABSEXECBASE EQU 4 ;Pointer to the Exec library base
- XMAGIC_ROMEND EQU $01000000 ;End of Kickstart ROM
- XMAGIC_SIZEOFFSET EQU -$14 ;Offset from end of ROM to Kickstart size
- XV36_EXEC EQU 36 ;Exec with the ColdReboot() function
- XTEMP_ColdReboot EQU -726 ;Offset of the V36 ColdReboot function
- X
- X
- X_ColdReboot: move.l ABSEXECBASE,a6
- X cmp.w #V36_EXEC,LIB_VERSION(a6)
- X blt.s old_exec
- X jmp TEMP_ColdReboot(a6) ;Let Exec do it...
- X ;NOTE: Control flow never returns to here
- X
- X
- X;---- manually reset the Amiga ---------------------------------------------
- Xold_exec: lea.l GoAway(pc),a5 ;address of code to execute
- X jsr _LVOSupervisor(a6) ;trap to code at (a5)...
- X ;NOTE: Control flow never returns to here
- X
- X
- X;-------------- MagicResetCode ---------DO NOT CHANGE-----------------------
- X CNOP 0,4 ;IMPORTANT! Longword align!
- XGoAway: lea.l MAGIC_ROMEND,a0 ;(end of ROM)
- X sub.l MAGIC_SIZEOFFSET(a0),a0 ;(end of ROM)-(ROM size)=PC
- X move.l 4(a0),a0 ;Get Initial Program Counter
- X subq.l #2,a0 ;now points to second RESET
- X reset ;first RESET instruction
- X jmp (a0) ;CPU Prefetch executes this
- X ;NOTE: the RESET and JMP instructions must share a longword!
- X;---------------------------------------DO NOT CHANGE-----------------------
- X END
- END_OF_FILE
- if test 2313 -ne `wc -c <'coldreboot.s'`; then
- echo shar: \"'coldreboot.s'\" unpacked with wrong size!
- fi
- # end of 'coldreboot.s'
- fi
- if test -f 'readme' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'readme'\"
- else
- echo shar: Extracting \"'readme'\" \(2450 characters\)
- sed "s/^X//" >'readme' <<'END_OF_FILE'
- X Amiga Software Reboot, Revisited
- X
- X By Bryce Nesbitt
- X
- X Copyright 1990 Commodore-Amiga, Inc. Permission granted to
- X reproduce in full ONLY. The information contained herein is
- X subject to change without notice, and is provided "as is" without
- X warranty of any kind, either express or implied. The entire risk
- X as to the use of this information is assumed by the user.
- X
- X
- XSometimes applications need to be able to reboot the Amiga under software
- Xcontrol. However, rebooting the machine is very tricky, and most attempts
- Xhave been flawed. The RESET instruction, for example, unconfigures all
- Xmemory; after RESET there is no reliable place to run user code. Most
- Xreboot code will break whenever the memory or CPU configuration is changed.
- XOther reset code will not work properly on the Amiga 1000.
- X
- XIn fact, rebooting the Amiga is so tricky that even the official reboot code
- Xpublished by Commodore will not work in every case. (This article replaces
- X"The Official Way to Software Reboot an Amiga" from the July/August 1989
- Xissue of Amiga Mail, Exec, page III-9.) Some versions of the A2000 have
- Xa 0.1 uf capacitor (C909) on the hardware reset line. This capacitor has
- Xthe effect of rejecting short reset pulses, including some of those generated
- Xby the CPU RESET instruction.
- X
- XThe ColdReboot() function listed below should be used whenever an application
- Xneeds to reboot the Amiga. ColdReboot() is the only officially supported way
- Xto reboot an Amiga under software control.
- X
- XEven this code will fail under some circumstances. Certain processor cards
- Xdeveloped by Great Valley Products (GVP) lock up when the RESET instruction
- Xis used. GVP offers an upgrade PAL to fix this problem. Likewise, if the
- Xuser has a 68020 or 68030 coprocessor card and has copied the Kickstart ROM
- Ximage into 32-bit memory with the command SetCPU FASTROM, the NewReboot()
- Xfunction will not work properly. To fix this, give the command SetCPU
- XNOFASTROM.
- X
- XTECHNICAL DESCRIPTION: The code below precalculates a jump address, executes
- Xa RESET instruction, then relies on CPU prefetch to execute the jump. The
- Xprecalculated jump is constructed to enter the system ROM at the location
- Xof a second RESET instruction.
- X
- X--
- X|\_/| . ACK!, NAK!, EOT!, SOH!
- X{o O} . Bryce Nesbitt, Commodore-Amiga, Inc.
- X (") BIX: bnesbitt
- X U USENET: bryce@commodore.COM -or- uunet!cbmvax!bryce
- XLawyers: America's untapped export market.
- END_OF_FILE
- if test 2450 -ne `wc -c <'readme'`; then
- echo shar: \"'readme'\" unpacked with wrong size!
- fi
- # end of 'readme'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
- Mail comments to the moderator at <amiga-request@cs.odu.edu>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-